package com.vhly.remoteapi.yahoo.contact;

import com.vhly.remoteapi.yahoo.contact.field.*;

/**
 * Created by IntelliJ IDEA.
 * User: vhly[FR]
 * Date: 11-1-10
 * Email: vhly@163.com
 */
public final class FieldValueProcess {
    public static FieldValue makeFieldValue(int type) {
        FieldValue ret = null;
        switch (type) {
            case 0:
                ret = new GUID();
                break;
            case 1:
                ret = new TextField(null);
                break;
            case 2:
                ret = new TextField(null);
                break;
            case 3:
                ret = new YahooID();
                break;
            case 4:
                ret = new OtherID();
                break;
            case 5:
                ret = new TextField(null);
                break;
            case 6:
                ret = new TextField(null);
                break;
            case 7:
                ret = new Company();
                break;
            case 8:
                ret = new Notes();
                break;
            case 9:
                ret = new TextField(null);
                break;
            case 10:
                break;
            case 11:
                ret = new Name(null);
                break;
            case 12:
                ret = new Birthday();
                break;
            case 13:
                ret = new Anniversary();
                break;
        }
        return ret;
    }

    public static int getFieldValueType(FieldValue value) {
        int ret = -1;
        if(value != null){
            if(value instanceof TextField){
                ret = 1;
            }else if (value instanceof GUID){
                ret = 0;
            }else if(value instanceof YahooID){
                ret = 3;
            }else if(value instanceof OtherID){
                ret = 4;
            }else if(value instanceof Company){
                ret = 7;
            }else if(value instanceof Notes){
                ret = 8;
            }else if(value instanceof Name){
                ret = 11;
            }else if(value instanceof Birthday){
                ret = 12;
            }else if(value instanceof Anniversary){
                ret = 13;
            }
        }
        return ret;
    }
}
